package com.withouther.robot.rainingrobot.util.ai.tts.ali;

import cn.hutool.setting.dialect.Props;
import com.withouther.robot.rainingrobot.util.ai.tts.TTSAudio;
import com.withouther.robot.rainingrobot.util.ai.tts.model.TTSParam;
import com.withouther.robot.rainingrobot.util.ai.tts.model.TTSResult;

/**
 * @ClassName TTSAudioALY
 * @Auther: tzq
 * @Date: 2020/9/24 11:57
 * @Description:
 */
public class TTSAudioALY implements TTSAudio {

    @Override
    public TTSResult textToAudio(TTSParam ttsParam) {
        TTSResult ttsResult = new TTSResult();
        ttsResult.setFilePath(ttsParam.getFilePath());
        Props props = new Props("ai.properties");
        String appkey = props.getStr("ali.tts.appKey");
        String accessKeyId = props.getStr("ali.accessKey");
        String accessKeySecret = props.getStr("ali.accessSecret");
        ttsParam.setFormat("WAV");
        ttsParam.setSampleRate(8000);
        ttsParam.setSpeechRate(0);
        ttsParam.setVoice("Aixia");
        SpeechSynthesizerUtil speechSynthesizerUtil = new SpeechSynthesizerUtil(appkey, accessKeyId, accessKeySecret, ttsParam);
        speechSynthesizerUtil.process();
        return ttsResult;
    }
}
